package com.ziqi.hututubackend.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ziqi.hututubackend.model.VO.SpaceVO;
import com.ziqi.hututubackend.model.dto.space.SpaceAddRequest;
import com.ziqi.hututubackend.model.dto.space.SpaceQueryRequest;
import com.ziqi.hututubackend.model.entity.Space;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ziqi.hututubackend.model.entity.User;

import javax.servlet.http.HttpServletRequest;

/**
* @author wang
* @description 针对表【space(空间)】的数据库操作Service
* @createDate 2025-02-06 18:55:58
*/
public interface SpaceService extends IService<Space> {

    /**
     * 查询空间请求
     * @param spaceQueryRequest
     * @return
     */
    QueryWrapper<Space> getQueryWrapper(SpaceQueryRequest spaceQueryRequest);


    /**
     *  分页获取空间封装类
     * @param spacePage
     * @param request
     * @return
     */
    Page<SpaceVO> getSpaceVOPage(Page<Space> spacePage, HttpServletRequest request);


    /**
     * 获取单个空间封装方法
     * @param space 原始空间对象
     * @param request 请求
     * @return
     */
    SpaceVO getSpaceVO(Space space, HttpServletRequest request);

    /**
     * 创建用户空间
     * @param spaceAddRequest
     * @param loginUser
     * @return
     */
    long addSpace(SpaceAddRequest spaceAddRequest, User loginUser);


    /**
     * 空间数据校验方法
     * @param space
     * @param add  判断是新增或修改 add==true创建操作
     */
    void vaildSpace(Space space, boolean add);


    /**
     * 根据空间级别填充限额数据
     * @param space
     */
    void fillSpaceBySpaceLevel(Space space);

    /**
     * 校验空间权限（仅管理员或用户可以访问
     * @param loginUser
     * @param space
     */
    void checkSpaceAuth(User loginUser, Space space);

}
